package oop.java0328.work2;

public class Cat {
    private String name;
    private float weight;
    private int energy;//体力

    public Cat() {
    }

    public Cat(String name, float weight, int energy) {
        this.name = name;
        this.weight = weight;
        this.energy = energy;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getWeight() {
        return weight;
    }

    public void setWeight(float weight) {
        this.weight = weight;
    }

    public int getEnergy() {
        return energy;
    }

    public void setEnergy(int energy) {
        this.energy = energy;
    }
    //玩耍
    public void play(){
        System.out.println("玩耍了半天");
        energy-=20;
        System.out.println(name+"当前体力值："+energy);
    }
    //捉老鼠
    public boolean catchMouse(Mouse mouse){
        System.out.println(name+"咬死了"+mouse.getName());
        energy+=mouse.getEnergy();
        mouse.setEnergy(0);
        System.out.println(name+"的体力上涨,体力值："+energy);
        System.out.println(mouse.getName()+"的体力值："+mouse.getEnergy());
        return true;
    }

}
